<template>
  <el-card shadow="never">
    <el-collapse-transition>
      <el-form ref="query" v-if="searchShow" :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-button type="primary" @click="getDataList()">{{ $t('query') }}</el-button>
          <el-button @click="searchReset()">{{ $t('reset') }}</el-button>
        </el-form-item>
      </el-form>
    </el-collapse-transition>
    <vxe-toolbar :custom="{immediate:true}">
      <template v-slot:buttons>
        <el-button v-if="$hasPermission('msg:msgNoDisturbing:save')" type="primary" @click="addOrUpdateHandle()">{{
          $t('add') }}</el-button>
        <el-button v-if="$hasPermission('msg:msgNoDisturbing:delete')" type="danger" @click="deleteHandle()">{{
          $t('deleteBatch') }}</el-button>
      </template>
      <template v-slot:tools>
        <el-button icon="el-icon-search" @click="searchShowHandle()" circle></el-button>
        <el-button icon="el-icon-refresh" @click="getDataList()" circle></el-button>
        <el-button icon="el-icon-download" @click="exportHandle()" circle></el-button>
      </template>
    </vxe-toolbar>
    <!--  锁定表头设置   :height="this.tableHeight" -->
    <vxe-table ref="xTable" :loading="dataListLoading" class="vxe-table-element" auto-resize :sort-config="{trigger:'cell'}"
      @sort-change="sortChange" @select-change="dataListSelectionChangeHandleVex" @select-all="dataListSelectionAllChangeHandleVex"
      :data="dataList">
      <vxe-table-column type="checkbox" align="center" width="60"></vxe-table-column>
      <vxe-table-column field="msgId" title="业务消息id">
      </vxe-table-column>
      <vxe-table-column field="ruleId" title="规则id">
      </vxe-table-column>
      <vxe-table-column field="userId" title="用户id">
      </vxe-table-column>
      <vxe-table-column field="bizId" title="关联业务id">
      </vxe-table-column>
      <vxe-table-column field="updater" title="更新者">
      </vxe-table-column>
      <vxe-table-column field="updateDate" title="最后更新时间">
      </vxe-table-column>
      <vxe-table-column title="handle" width="120" show-overflow="false" fixed="right" align="center">
        <template slot-scope="scope">
          <el-button v-if="$hasPermission('msg:msgNoDisturbing:update')" type="text" size="small" icon="el-icon-edit"
            @click="addOrUpdateHandle(scope.row)">{{ $t('update') }}</el-button>
          <el-button v-if="$hasPermission('msg:msgNoDisturbing:delete')" type="text" size="small" icon="el-icon-delete"
            @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
        </template>
      </vxe-table-column>
    </vxe-table>
    <el-pagination :current-page="page" :page-sizes="pageSizes" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper"
      @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle">
    </el-pagination>
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  </el-card>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './msgNoDisturbing-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      searchShow: true,
      mixinViewModuleOptions: {
        getDataListURL: '/msg/msgNoDisturbing/page',
        getDataListIsPage: true,
        deleteURL: '/msg/msgNoDisturbing',
        deleteIsBatch: true,
        exportURL: '/msg/msgNoDisturbing/export'
      },
      headLock: false,
      dataForm: {
      }
    }
  },
  components: {
    AddOrUpdate
  },
  methods: {
    // 新增 / 修改
    addOrUpdateHandle (row) {
      let id
      if (row) {
        id = row.id
      }
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.dataForm.id = id
        this.$refs.addOrUpdate.init()
      })
    }
  }
}
</script>
